import { followOrUnfollow } from '@/services/consule'
import type { FollowType } from '@/types/consult'
import { ref } from 'vue'
export const useFollw = (type: FollowType = 'doc') => {
  const loading = ref(false)
  const followOrUnfollowLike = async (item: {
    id: string
    likeFlag: 0 | 1
  }) => {
    loading.value = true
    try {
      await followOrUnfollow(item.id, type)
      item.likeFlag = item.likeFlag === 1 ? 0 : 1
    } finally {
      loading.value = false
    }
  }
  return { loading, followOrUnfollowLike }
}
